package com.asialjim.wechat.pojo.account;

/**
 * <h1><em>ASIAL JIM JAVA DOC</em></h1><hr/>
 * <h2>CLASS DESCRIPTION <i>[ NAME: WeChatAccountHolder ]</i></h2><strong>
 * <p> we chat account holder
 * </strong><p><p><em>Copyright &copy; Asial Jim Co., LTD</em><hr/>
 *
 * @author Asial Jim &nbsp;&nbsp; <span>Email:<a href="mailto:asialjim@hotmail.com">asialjim@hotmail.com</a> &nbsp;&nbsp; <a href="asialjim@qq.com">asialjim@qq.com</a></span>
 * @version 1.0.0
 * @since 2021/2/27   &nbsp;&nbsp; JDK 8
 */
public class WeChatAccountHolder {
    private static final ThreadLocal<WeChatAccount> WE_CHAT_ACCOUNT_THREAD_LOCAL = new ThreadLocal<>();
    private static final ThreadLocal<String> TO_USER_NAME_THREAD_LOCAL = new ThreadLocal<>();

    /**
     * <h3>METHOD DESCRIPTION <i>[ NAME: set ]</i></h3>
     * set we chat account
     * @param weChatAccount {@link WeChatAccount we chat account}

     * @author Asial Jim &nbsp;&nbsp;<span>Email:asialjim@hotmail.com &nbsp;&nbsp; asialjim@qq.com</span>
     * @since 2021/2/27 11:46
     */
    public static void set(WeChatAccount weChatAccount){
        WE_CHAT_ACCOUNT_THREAD_LOCAL.set(weChatAccount);
    }

    /**
     * <h3>METHOD DESCRIPTION <i>[ NAME: get ]</i></h3>
     * get we chat account
     * @return {@link WeChatAccount we chat account}
     * @author Asial Jim &nbsp;&nbsp;<span>Email:asialjim@hotmail.com &nbsp;&nbsp; asialjim@qq.com</span>
     * @since 2021/2/27 11:46
     */
    public static WeChatAccount get(){
        return WE_CHAT_ACCOUNT_THREAD_LOCAL.get();
    }

    /**
     * <h3>METHOD DESCRIPTION <i>[ NAME: remove ]</i></h3>
     * remove we-chat account
     * @author Asial Jim &nbsp;&nbsp; <span>Email: &nbsp;&nbsp; <a href="mailto:asialjim@hotmail.com">asialjim@hotmail.com</a> &nbsp;&nbsp; <a href="asialjim@qq.com">asialjim@qq.com</a></span>
     * @since 2021/3/11 13:54
     */
    public static void remove(){
        WE_CHAT_ACCOUNT_THREAD_LOCAL.remove();
    }

    /**
     * <h3>METHOD DESCRIPTION <i>[ NAME: setToUserName ]</i></h3>
     * set to user name
     * @param toUserName {@link String to user name,the we-chat open platform application open id}

     * @author Asial Jim &nbsp;&nbsp;<span>Email:asialjim@hotmail.com &nbsp;&nbsp; asialjim@qq.com</span>
     * @since 2021/3/16 11:17
     */
    public static void setToUserName(String toUserName){
        TO_USER_NAME_THREAD_LOCAL.set(toUserName);
    }

    /**
     * <h3>METHOD DESCRIPTION <i>[ NAME: getToUserName ]</i></h3>
     * get to user name
     * @return {@link String to user name}
     * @author Asial Jim &nbsp;&nbsp;<span>Email:asialjim@hotmail.com &nbsp;&nbsp; asialjim@qq.com</span>
     * @since 2021/3/16 11:18
     */
    public static String getToUserName(){
        return TO_USER_NAME_THREAD_LOCAL.get();
    }

    /**
     * <h3>METHOD DESCRIPTION <i>[ NAME: removeToUserName ]</i></h3>
     * remove to user name
     * @author Asial Jim &nbsp;&nbsp;<span>Email:asialjim@hotmail.com &nbsp;&nbsp; asialjim@qq.com</span>
     * @since 2021/3/16 11:18
     */
    public static void removeToUserName(){
        TO_USER_NAME_THREAD_LOCAL.remove();
    }
}
